package com.lcxw.hxzbadmin.dao.adminmapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import com.lcxw.hxzbadmin.entity.pojo.AdminUser;

@Component
@Mapper
public interface AdminUserMapper {

    // TODO: 2020/7/4 表字段创建索引   
    @Select("select * from ywpd_admin where adminName=#{adminName}")
    AdminUser queryAdminByName(String adminName) throws Exception;


    @Update({"UPDATE ywpd_admin SET id = #{id},adminname=#{adminName},password=#{password},"
        + "lastLogTime=#{lastLogTime},lastLogIp=#{lastLogIp},addTime=#{addTime}"
        + " WHERE adminname=#{adminName}"})
    int updateAdminByName(AdminUser adminUser) throws Exception;

    @Insert({
        "insert into ywpd_admin (`adminname`,adminType, `password`, ",
        "`lastlogtime`, `lastlogip`, ",
        "`addtime`)",
        "values (#{adminName},#{adminType}, #{password}, ",
        "#{lastLogTime}, #{lastLogIp}, ",
        "#{addTime})"
    })
    int insert(AdminUser adminUser) throws Exception;

    @Delete({
        "delete from ywpd_admin",
        "where `id` = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id) throws Exception;

}
